package com.kd.service.admin.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kd.bean.admin.Notice_admin;
import com.kd.dao.admin.INotice_adminDao;
import com.kd.service.admin.INotice_adminService;


@Service
@Transactional
public class Notice_adminServiceImpl implements INotice_adminService{

	@Autowired
	private INotice_adminDao adminDao;
	
	@Override
	public List<Notice_admin> queryByNoticeWhereState() throws Exception {
		
		return adminDao.queryByNoticeWhereState();
	}

	@Override
	public PageInfo<Notice_admin> queryAllNotice(Integer pageNum, Integer pageSize) throws Exception {
		PageHelper.startPage(pageNum, pageSize);
		List<Notice_admin> list = adminDao.queryAllNotice();
		PageInfo<Notice_admin> info = new PageInfo<>(list);
		return info;
	}

	@Override
	public Boolean insertNotice(Notice_admin notice) throws Exception {
		notice.setNotice_create_time(new Date());
		
		return adminDao.insertNotice(notice)>0;
	}

	@Override
	public Boolean removeNotice(Integer notice_id, Integer notice_state) throws Exception {
		
		return adminDao.removeNotice(notice_id, notice_state)>0;
	}

	@Override
	public Notice_admin queryByNotice_id(Integer notice_id) throws Exception {
		
		return adminDao.queryByNotice_id(notice_id);
	}

	@Override
	public Boolean updateNotice(Notice_admin notice) throws Exception {
		
		return adminDao.updateNotice(notice)>0;
	}

}
